package com.hyg.base.utils;

import com.liulishuo.okdownload.DownloadTask;

import java.io.File;

/**
 * FileName: SaveFileUtils
 * Author: huangyuguang
 * Date: 2022/6/21
 * Description:
 */
public class SaveFileUtils {

    public static String FILE_TYPE_APK = "application/vnd.android.package-archive";

    public static DownloadTask downloadCommonFile(String url, String parentDir, String fileName, StickersListener.StickersProgress listener){
        File file = new File(parentDir);
        if (file.exists() || (!file.exists() && file.mkdirs())) {
            DownloadTask downloadTask = new DownloadTask.Builder(url, parentDir, fileName).setMinIntervalMillisCallbackProcess(30)
                    .setPassIfAlreadyCompleted(true)
                    .setConnectionCount(1)
                    .build();
            downloadTask.enqueue(new StickersListener(listener));
            return downloadTask;
        }

        return null;
    }
}
